home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ray Dream Studio
/
Ray Dream Studio (CDRAYD1) (Ray Dream) (1995).iso
/
DREAMSDK.WIN
/
INCLUDE
/
3DCOFAIL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-04
|
4KB
|
117 lines
/* $Id: 3DCOFAIL.h 1.2 1995/11/04 14:51:46 YannPC Exp $ */
/*****************************************************************************\
* *
* 3DCoFail.h *
* Failure handling for COM extensions *
* *
* Copyright (c) 1995, Ray Dream, Inc. All rights reserved. *
* *
\*****************************************************************************/
#ifndef __3DCOFAIL__
#define __3DCOFAIL__
struct IShUtilities;
/*****************************************************************************\
* *
* Shell Utilities pointer *
* *
\*****************************************************************************/
// gShellUtilities keeps a pointer on the Shell Utilities interface as given by
// I3DExtension::ShellUtilitiesInit(). This is used as a convenient back-door
// to the Shell. gShellUtilities is NULL by default, and is initialized by
// InitCoFailure() (this is pretty much all what InitCoFailure() does).
extern IShUtilities* gShellUtilities;
/*****************************************************************************\
* *
* Failure Handling *
* *
\*****************************************************************************/
// Initialize gShellUtilities. Must be called to have working failure handling
void InitCoFailure(IShUtilities* shellUtilities);
// Failure handling
typedef int jmp_buf[16];
#ifdef __cplusplus
extern "C" {
#endif
void FailNIL(void* apointer);
void FailOSErr(short err);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#define VOLATILE(a) ((void)&a)
#define DECLAREVOLATILE(a,b) a volatile b;
class FailInfo {
public:
jmp_buf savedState;
short error;
long message;
FailInfo* nextInfo;
public:
FailInfo();
inline void ReSignal();
inline void Success();
inline void Reset();
};
typedef FailInfo* FailInfoPtr;
extern "C" {
void __cdecl Failure(short error, long message);
FailInfoPtr* __cdecl GetGTopHandler();
typedef int (*RDsetjmpProc)(jmp_buf);
extern RDsetjmpProc RDsetjmp;
}
//----------------------------------------------------------------------------------------
// FailInfo inline method definitions
//----------------------------------------------------------------------------------------
#define TRY(f) \
f.nextInfo = *GetGTopHandler(), \
(f.nextInfo ? (*GetGTopHandler() = &f, ((*RDsetjmp)(f.savedState)==0)) : 1)
inline void FailInfo::Reset() {
error = 0;
message = 0;
nextInfo = 0;
}
inline FailInfo::FailInfo() {
}
inline void FailInfo::ReSignal() {
::Failure(error, message);
}
inline void FailInfo::Success() {
*GetGTopHandler() = nextInfo;
}
#endif /* __cplusplus */
/*****************************************************************************\
* *
* Memory management *
* *
\*****************************************************************************/
void* RDmalloc(unsigned long size);
void* RDcalloc(unsigned long nmemb, unsigned long size);
void* RDrealloc(void* ptr, unsigned long size);
void* RDcrealloc(void* ptr, unsigned long size);
void RDfree(void* ptr);
#endif